<template>
  <div class="list">
    <van-nav-bar left-text="歌单广场" left-arrow @click-left="onClickLeft" />

    <!-- 排行榜列表 -->
    <div class="ranking">
      <div
        class="listbox"
        v-for="(item, index) in resultData"
        :key="index"
        @click="viewSongsheet(item.id)"
      >
        <div class="img">
          <img :src="item.picUrl" alt="" />
        </div>

        <div class="text">{{ item.name }}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Rankinglist",

  data() {
    return {
      resultData: [],
    };
  },

  created() {
    //获取歌单数据
    this.getCatlist();
  },

  methods: {
    //返回
    onClickLeft() {
      this.$router.go(-1);
    },

    //获取歌单数据
    getCatlist() {
      this.axios({
        method: "get",
        url: "/personalized",
      })
        .then((res) => {
          this.resultData = res.data.result;
        })
        .catch((err) => {
          
        });
    },

    //查看歌单页面
    viewSongsheet(id) {
      this.$router.push({ name: "Songsheet", params: { id } });
    },
  },
};
</script>

<style lang="less" scoped>
//导航栏
/deep/.van-nav-bar .van-icon {
  color: #3e3e3e;
  font-weight: 600;
}

/deep/.van-nav-bar__text {
  color: #3e3e3e;
  font-weight: 600;
}

// 排行榜列表
.ranking {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  margin-top: 10px;
}

.listbox {
  width: 30%;
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.img {
  width: 100%;
  height: 120px;
  border-radius: 10px;
}

.img img {
  width: 100%;
  height: 120px;
  border-radius: 10px;
}

.text {
  width: 100%;
  padding-top: 4px;
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
</style>